/*
 * Copyright 2016 Red Hat, Inc. and/or its affiliates.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.drools.workbench.screens.guided.dtable.service;

import org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52;

/**
 * Definition of service to maintain links between Decision Tables.
 */
public interface GuidedDecisionTableLinkManager {

    /**
     * Create links between one Guided Decision Table and others. Existing links should be removed and re-created.
     * @param sourceModel
     *         The Decision Table to link from.
     * @param targetModel
     *         Another potential Decision Table that may be linked to.
     * @param callback
     *         Called when a link between the model and otherModel has been found.
     */
    void link( final GuidedDecisionTable52 sourceModel,
               final GuidedDecisionTable52 targetModel,
               final LinkFoundCallback callback );

    /**
     * Callback when a link is found.
     */
    interface LinkFoundCallback {

        /**
         * Links a source column index and target column index. The source and target models are those provided to
         * the {@link GuidedDecisionTableLinkManager#link(GuidedDecisionTable52, GuidedDecisionTable52, LinkFoundCallback)}
         * method.
         * @param sourceColumnIndex
         *         The source index relative to GuidedDecisionTable52.getExpandedColumns()
         * @param targetColumnIndex
         *         The target index relative to GuidedDecisionTable52.getExpandedColumns()
         */
        void link( final int sourceColumnIndex,
                   final int targetColumnIndex );

    }

}
